<?php
/**
*
* @package ppkBB3cker
* @version $Id: top_by_upload.php 1.000 2010-04-20 10:34:00 PPK $
* @copyright (c) 2010 PPK
* @Based on Top v.2.0 for tt.u-l.ru (c) Boec
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

//TOP_BY_UPLOAD
$sql = "SELECT u.username, u.user_id, u.user_bonus, u.user_uploaded, u.user_downloaded, u.user_torrents
	FROM " . USERS_TABLE . " u
	where u.user_uploaded>0
	ORDER BY u.user_uploaded DESC
	LIMIT $top_limit";

if( !($result = $db->sql_query($sql, $config['ppkbb_tstat_ctime']*60)) )
{
	//message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
	$i = 0;
	do
	{
		$username = $row['username'];
		$user_id = $row['user_id'];
		$download = $row['user_downloaded'];
		$upload = $row['user_uploaded'];
		$bonus = $row['user_bonus'];
		$poster_id = $row['user_id'];
		$ratio = get_ratio_alias(get_ratio($row['user_uploaded'], $row['user_downloaded'], $config['ppkbb_tcratio_start'], $row['user_bonus']));
		$rratio = get_ratio_alias(get_ratio($row['user_uploaded'], $row['user_downloaded'], $config['ppkbb_tcratio_start']));
		$row_class = ( !($i % 2) ) ? 'row1' : 'row2';

		$template->assign_block_vars('memberrow1', array(
			'ROW_NUMBER' => $i + ( $start + 1 ),
			'ROW_CLASS' => $row_class,
			'USERNAME' => $username,
			'RELEASES' => $row['user_torrents'],
			'UP_DOWN_RATIO' => $ratio,
			'UP_DOWN_RRATIO' => $rratio,
			'UP' => get_formatted_filesize($upload),
			'DOWN' => get_formatted_filesize($download),
			'BONUS' => $row['user_bonus'],
			'U_VIEWPROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;u=$user_id"))
		);
		$i++;
	}
	while ( $row = $db->sql_fetchrow($result) );
	$db->sql_freeresult($result);
}

?>
